<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
  <head>
    <meta charset="utf-8" />
    <meta name="generator" content="pandoc" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1.0, user-scalable=yes"
    />
    <title>10_External_Python_packages_you_are_going_to_love</title>
    <style type="text/css">
      code {
        white-space: pre-wrap;
      }
      span.smallcaps {
        font-variant: small-caps;
      }
      span.underline {
        text-decoration: underline;
      }
      div.column {
        display: inline-block;
        vertical-align: top;
        width: 50%;
      }
    </style>
  </head>
  <body>
    <h1 id="external-python-packages-you-are-going-to-love">
      10 External Python packages you are going to love
    </h1>
    <blockquote>
      <p>
        by Adam Goldschmidt 10 External Python packages you are going to
        lovePhoto by Brina Blum on UnsplashPython is an experiment in how much
        freedom programmers need. Too much freedom and nobody can read another’s
        code; too little and expressiveness is endangered. - Guido van
        RossumThis freedom that Guido talks
      </p>
    </blockquote>
    <figure>
      <img
        src="https://cdn-media-1.freecodecamp.org/images/0*Metg2GPm6OTYWKZh"
        alt="10 External Python packages you are going to love"
      />
      <figcaption>10 External Python packages you are going to love</figcaption>
    </figure>
    <p>by Adam Goldschmidt</p>
    <p>
      <img
        src="https://cdn-media-1.freecodecamp.org/images/Tehd4MeGX2yYQUFUtdcWWNbUE7Qk9qFsZ9-Z"
      />
    </p>
    <p>
      Photo by
      <a
        href="https://unsplash.com/@brina_blum?utm_source=medium&amp;utm_medium=referral"
        >Brina Blum</a
      >
      on
      <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral"
        >Unsplash</a
      >
    </p>
    <blockquote>
      <p>
        Python is an experiment in how much freedom programmers need. Too much
        freedom and nobody can read another’s code; too little and
        expressiveness is endangered. - Guido van Rossum
      </p>
    </blockquote>
    <p>
      This freedom that Guido talks about is part of what makes Python so
      popular. That popularity, among other, is what attracts more and more
      developers to use the language - eventually leading to some really amazing
      open source projects.
    </p>
    <p>
      I usually find myself project hunting on GitHub once a day. Throughout
      this article, I will try to cover 10 wonderful packages that you may or
      may not be familiar with. I will start from the less trendy and end up
      with… well, Flask.
    </p>
    <h3 id="lets-begin">Let’s begin!</h3>
    <p>
      <img
        src="https://cdn-media-1.freecodecamp.org/images/oGpPuDrsAM6KYONzQCrIZXv1xAEIv-oVuIUT"
      />
    </p>
    <h4 id="loguru-logging-made-easy">
      <a href="https://github.com/Delgan/loguru">Loguru</a> — Logging made easy
    </h4>
    <p>
      <img
        src="https://cdn-media-1.freecodecamp.org/images/DWrohhPZvoWbH4s8apMbg8nXZOtf3m0lAhvk"
      />
    </p>
    <p>
      This is a really awesome package I regularly use in my projects. It
      describes itself as “a library which aims to bring enjoyable logging in
      Python”. This package just lets you easily configure your logs out of the
      box.
    </p>
    <p>All you have to do after installing is to import the module:</p>
    <pre><code>from loguru import logger</code></pre>
    <p>And you’re free to use it out of the box:</p>
    <pre><code>logger.debug(&quot;Hello, cool debugger&quot;)</code></pre>
    <p>The documentation is good and there are many customization options.</p>
    <h4 id="more-itertools">
      <a href="https://github.com/erikrose/more-itertools">more-itertools</a>
    </h4>
    <p>
      A variety of interesting methods that could sometimes come very useful,
      such as <code>peekable</code>:
    </p>
    <pre><code>&gt;&gt;&gt; p = peekable([&#39;a&#39;, &#39;b&#39;])&gt;&gt;&gt; p.peek()&#39;a&#39;&gt;&gt;&gt; next(p)&#39;a&#39;</code></pre>
    <p>or <code>chunked</code>:</p>
    <pre><code>&gt;&gt;&gt; list(chunked([1, 2, 3, 4, 5, 6], 3))[[1, 2, 3], [4, 5, 6]]</code></pre>
    <h4 id="monkeytype-static-type-annotations-generator">
      <a href="https://github.com/Instagram/MonkeyType">MonkeyType</a> — Static
      type annotations generator
    </h4>
    <pre><code>monkeytype run myscript.py</code></pre>
    <p>
      This package automatically generates type annotations for you, either in a
      stub file or in the source code itself, by collecting runtime types.
      Right, Python doesn’t enforce you to use annotations — but I believe they
      are very important for readability of the code (and sometimes for avoiding
      errors), which is also why there are 2 more packages in this list that are
      handling type annotations :)
    </p>
    <h4 id="pyright-static-type-checker">
      <a href="https://github.com/Microsoft/pyright">Pyright</a> — Static type
      checker
    </h4>
    <p>
      <img
        src="https://cdn-media-1.freecodecamp.org/images/B5KVRNqA90q0PqVY18dvfvc7m7rbjYYVf1EP"
      />
    </p>
    <p>
      Exciting new package coming from Microsoft. The inital commit was just 17
      days ago! This package is the competitor of Mypy (also on this list). To
      be honest, I haven’t yet had the chance to use it, but I definitely plan
      to. I currently use mypy as a type checker, but I’ll give this one a try!
    </p>
    <h4 id="requests-async-support-for-asyncawait-syntax-for-requests">
      <a href="https://github.com/encode/requests-async">requests-async</a> —
      support for <code>async</code>/<code>await</code> syntax for
      <code>requests</code>
    </h4>
    <p>
      This is a new package I discovered the other day on GitHub, and it seems
      pretty promising. We all know the
      <a href="https://github.com/kennethreitz/requests">requests</a> package,
      that lets us easily handle HTTP requests in our code. Well, this package
      implements <code>async</code> and <code>await</code> words for these
      requests:
    </p>
    <pre><code>import requests_async as requests​response = await requests.get(&#39;https://example.org&#39;)print(response.status_code)print(response.text)</code></pre>
    <p>Pretty cool right?</p>
    <h4 id="httpie-modern-command-line-curl">
      <a href="https://github.com/jakubroztocil/httpie">HTTPie</a> — Modern
      command line cURL
    </h4>
    <p>
      <img
        src="https://cdn-media-1.freecodecamp.org/images/UAD--5ZtcqjDRRKA4Y1oXEWzob6GTM94sXGa"
      />
    </p>
    <p>
      Those of you who have used cURL before, must know it’s not that fun.
      Having to remember the parameters names, making sure your data is
      encapsulated… Well, HTTPie aims to make this much easier. Here’s one of
      their examples, of submitting form data:
    </p>
    <pre><code>http -f POST example.org hello=World</code></pre>
    <h4 id="pipenv-better-packaging-for-python">
      <a href="https://github.com/pypa/pipenv">pipenv</a> — Better packaging for
      Python
    </h4>
    <p>
      When I start a new project, I always create a new
      <code>virtualenv</code> and install some basic packages with
      <code>pip</code>. I then need to save these packages names in a file, be
      it <code>setup.py</code> or <code>requirements.txt</code>. Those of you
      who have worked with <code>npm</code>, know it’s much simpler there. All
      you need to do is write <code>npm —save</code> and the package name is
      saved in your <code>package.json</code>. That’s why I first created
      <a href="https://github.com/AdamGold/pypkgfreeze">pypkgfreeze</a>, a
      simple package to “freeze” the versions of your currently used
      <code>pip</code> packages into <code>setup.py</code>.
    </p>
    <p>
      Anyway, pipenv is an interesting solution that aims to merge the two
      worlds - They describe it best in their repo page:
    </p>
    <p>
      It automatically creates and manages a virtualenv for your projects, as
      well as adds/removes packages from your <code>Pipfile</code> as you
      install/uninstall packages. It also generates the ever-important
      <code>Pipfile.lock</code>, which is used to produce deterministic builds.
    </p>
    <p>
      You can try it out <a href="https://rootnroll.com/d/pipenv/">here</a>.
    </p>
    <h4 id="mypy-static-type-checker">
      <a href="https://github.com/python/mypy">mypy</a> — Static type checker
    </h4>
    <p>
      As I said before, this is the package I currently use as my standard
      static type checker. It helps me keep my code readable and elegant (I
      think).
    </p>
    <h4 id="black"><a href="https://github.com/ambv/black">black</a></h4>
    <p>
      <img
        src="https://cdn-media-1.freecodecamp.org/images/dQoUny7l5N6sWs2GCECZKHALf59t9398hNNp"
      />
    </p>
    <p>
      I have tried many Python formatters, and <code>black</code> is clearly my
      favourite. The syntax looks neat, and the command line runs quick and can
      either check the files or actually edit them - very useful for CI/CD. You
      can even try it
      <a
        href="chrome-extension://cjedbglnccaioiolemnfhjncicchinao/%5Bhttps://black.now.sh%5D(https://black.now.sh/)"
        >here!</a
      >
    </p>
    <h4 id="flask"><a href="https://github.com/pallets/flask">flask</a></h4>
  </body>
</html>
